package com.yunmai11.yunmai.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.yunmai11.yunmai.R;
import com.yunmai11.yunmai.adapter.OrderListAdapter;
import com.yunmai11.yunmai.bean.OrderBean;
import com.yunmai11.yunmai.utils.CommonUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/1/19.
 */
public class OrderListActivity extends Activity implements OrderListAdapter.MyOnItemClickListener {
    private RecyclerView rl_order_list;
    private OrderListAdapter mAdapter;
    private List<OrderBean> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.order_list);

        genDatas();
        rl_order_list = (RecyclerView) findViewById(R.id.rl_order_list);
        rl_order_list.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        //TODO 来个分割线吧
        rl_order_list.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

        mAdapter = new OrderListAdapter(this, list);
        mAdapter.addOnItemClickListener(this);
        rl_order_list.setAdapter(mAdapter);

    }

    private void genDatas() {
        list = new ArrayList<OrderBean>();
        for(int i=0;i<20;i++) {
            list.add(new OrderBean("LG000000"+i, "Apple"+i,(i+1)*250));
        }
    }

    @Override
    public void onClick(View v, int position) {
        CommonUtils.showToast(this, "你点击了->"+position);
    }
}
